package com.fzs.sshd.cli.server.filter;

import lombok.extern.slf4j.Slf4j;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.util.net.SshdSocketAddress;
import org.apache.sshd.server.forward.TcpForwardingFilter;

/**
 * 动态tcp校验
 */
@Slf4j
public class ADBTcpForwardingFilter implements TcpForwardingFilter {
    @Override
    public boolean canListen(SshdSocketAddress sshdSocketAddress, Session session) {
        return false;
    }

    @Override
    public boolean canConnect(Type type, SshdSocketAddress sshdSocketAddress, Session session) {
        //打印-L的目标地址
        log.info("tcp host:{}, port:{}", sshdSocketAddress.getHostName(),  sshdSocketAddress.getPort());
        return true;
    }
}
